String.prototype.format = function( ps ){
    let str = this 
    const len = str.length 
    let replace = ""
    let findKey = ""
    let isStart = false  
    for( let i = 0 ; i < len ; i ++ ){
        const v = str[ i ]
        if( v == "{"){
            isStart = true 
            findKey = ""
        }else if( v == "}"){
            isStart = false 
            replace += ps[ findKey ] || ("{" + findKey + "}")
        }else{
            if( isStart )
                findKey += v 
            else 
                replace += v 
        }
    }
    return replace 
}

class Str {
    static format( str , ps ){
        return str.format( ps )
    }
}

module.exports = Str 